//
//  HJDTabBar.m
//  JYHospital
//
//  Created by 胡金东 on 16/3/31.
//  Copyright © 2016年 胡金东. All rights reserved.
//

#import "HJDTabBar.h"

@interface HJDTabBar()

@property (nonatomic,strong) UIButton *plusBtn;

@end

@implementation HJDTabBar
//咨询预约按钮
//-(UIButton *)plusBtn
//{
//    if (_plusBtn ==nil) {
//        UIButton *consultBtn = [UIButton buttonWithType:UIButtonTypeCustom];
//       
//        
//        [consultBtn setImage:[UIImage imageNamed:@"tabbar_compose_icon_add"] forState:UIControlStateNormal];
//        [consultBtn setImage:[UIImage imageNamed:@"tabbar_compose_background_icon_add"] forState:UIControlStateHighlighted];
//        [consultBtn setBackgroundImage:[UIImage imageNamed:@"tabbar_compose_button"] forState:UIControlStateNormal];
//        [consultBtn setBackgroundImage:[UIImage imageNamed:@"tabbar_compose_button_highlighted"] forState:UIControlStateHighlighted];
//        
//          _plusBtn = consultBtn;
//        
//        [self addSubview:_plusBtn];
//        [consultBtn sizeToFit];
//        
//      
//        
//    }
//    return _plusBtn;
//}

-(void)layoutSubviews
{
    CGFloat w = self.bounds.size.width;
    CGFloat h = self.bounds.size.height;
    [super layoutSubviews];
    CGFloat btnX = 0;
    CGFloat btnY = 0;
    CGFloat btnW = w/(self.items.count);
    //像微博可以添加按钮
//    CGFloat btnW = w/(self.items.count+1);
    CGFloat btnH = h;
    
    int i = 0;
    //调整系统自带的tabBar上的按钮的位置
//        NSLog(@"%@",self.subviews);//打印出所有的子控件
    for (UIView *tabBarButton in self.subviews) {
        //tabBarButton从 HJDTabBar类查找，但是直接写不出这个类，所以用放射机制用子控件（UITabBarButton）去找这个类
        if ([tabBarButton isKindOfClass:NSClassFromString(@"UITabBarButton")]) {
            //把后两个控件移动一下
//            if (i==1) {
//                i=1;
//            }
            btnX = i*btnW;
            tabBarButton.frame = CGRectMake(btnX, btnY, btnW, btnH);
            i++;
        }
    }
//    self.plusBtn.center = CGPointMake(w*0.5, h*0.5);
//    self.plusBtn.bounds = CGRectMake(0, 0, self.plusBtn.currentBackgroundImage.size.width, self.plusBtn.currentBackgroundImage.size.height);
}

@end
